//
//  WYUserStatues.swift
//  weibo
//
//  Created by 王玉东 on 16/4/12.
//  Copyright © 2016年 wyd. All rights reserved.
//

import UIKit

class WYUserStatues: NSObject {
    
    var id: Int64 = 0
    
    var text : String?
    
    var user : WYUser?
    //创建时间
    var created_at: String?
    //微博来源
    var source: String?
    
    var retweeted_status: WYUserStatues?
    //转发数量
    var reposts_count: Int = 0
    //评论数量
    var coments_count: Int = 0
    //赞的数量
    var attitudes_count: Int = 0
    
   // var source: String?
    
    //var time: String?
    
    var pic_urls: [WYStatusPicture]?
  
    init(dic:[String : AnyObject]) {
       
        super.init()
        setValuesForKeysWithDictionary(dic)
    }
    //字典转模型时调用这个方法
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {

            user = WYUser(dict: (value as! [String:AnyObject]))
            
            return
        }
        
        if key == "retweeted_status" {
        
            retweeted_status = WYUserStatues(dic: value as! [String : AnyObject])
            
            return
        }
        
        if key == "pic_urls"{
        
            let array = value as! [[String : String ]]
            
            var temArray = [WYStatusPicture]()
            
            for item in array{
            
                let pic = WYStatusPicture(dict: item)
                temArray.append(pic)
            }
            pic_urls = temArray
            return
        }
        
        super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
}
